(function($){    
    var _plainTooltipTmp = [
        '<span class="<%=o.theme%>">',
            '<%=o.text%>',
        '</span>'
    ].join('');
    
    var _Tooltip = function(selector, cfg){
        var _this = this,
            defCfg = {};
        
        _this.config = $.extend({}, defCfg, cfg);   
        _this.$holder = $(selector); 
        _this.$wrapper = $( tmpl(_plainTooltipTmp, _this.config) ).addClass('tooltip').appendTo(_this.$holder);
        
        if(!_this.$holder.isPositioned()){
            _this.$holder.css('position', 'relative');
        }        
        _this.$wrapper.style(_this.config['style']);
    };
    
    //init interface.
    $.fn.tooltip = function(cfg){        
        this.each(function(){
            var tooltipObj = new _Tooltip(this, cfg);
            Observable.enable(tooltipObj);
            Observable.regEvent(tooltipObj, cfg, function(){
                this.fire('init', this);
            });                   
            $(this).data('tooltip', tooltipObj);
        });
        return this;
    };
    
})(jQuery);